<?php

namespace App\Services\Manage;

use App\Services\ProjectValidate;

class ValidateApi extends ProjectValidate
{

    /**
     * 自定义子类初始化
     * @param array $initData
     * @return mixed
     */
    public function initValidate($initData = [])
    {
        if (isset($initData['requiredId']) && $initData['requiredId'] == true) {
            $this->rules['id']  = 'required|int|min:1';
        }
    }


    /**
     * @var array 验证规则集合
     */
    public $rules = [
        'id'                    => 'int|min:1',
        'api_cate_id'           => 'int|min:0',
        'action_flag'           => 'alpha_num|min:2|max:50',
        'module'                => 'string|min:2|max:50',
        'controller'            => 'string|min:2|max:50',
        'action'                => 'string|min:2|max:50',
        'text_data'             => 'string|min:2',
        'need_login'            => 'in:0,1',
        'author'                => 'string|min:2|max:20',
        'job_schedule'          => 'between|-2,1',
        'rewrite_status'        => 'in:0,1'
    ];

    /**
     * @var array 当前验证错误信息
     */
    public $messages = [
    ];

    /**
     * @var array 上面规则中定义的 key 的名字
     */
    public $attributes = [
    ];
}